#define  _CRT_SECURE_NO_WARNINGS

#include <iostream>
using namespace std;
#include <string>
#include <vector>
int main() {
    string str;
    cin >> str;
    int n = str.size();
    vector<vector<int>> v(n, vector<int>(n, 1));
    for (int i = n - 2; i >= 0; i--)
        for (int j = i + 1; j < n; j++)
        {
            if (str[i] == str[j])
            {
                if (i + 1 == j)
                    v[i][j] = 2;
                else v[i][j] = v[i + 1][j - 1] + 2;
            }
            else
                v[i][j] = max(v[i + 1][j], v[i][j - 1]);
        }
    cout << v[0][n - 1];
    return 0;
}